Socket
Socket
Sign inDemoInstall

docker-modem

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docker-modem

Docker remote API network layer module.


Version published
Weekly downloads
820K
increased by4.75%
Maintainers
1
Weekly downloads
 
Created

What is docker-modem?

The docker-modem npm package is a low-level Docker API client for Node.js. It allows developers to interact with Docker's REST API programmatically, enabling them to manage Docker containers, images, networks, and more directly from their Node.js applications.

What are docker-modem's main functionalities?

Managing Containers

This feature allows you to create and manage Docker containers. The code sample demonstrates how to create a new container using the 'alpine' image and run a simple command inside it.

const Docker = require('docker-modem');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });

const createContainer = async () => {
  const opts = {
    path: '/containers/create',
    method: 'POST',
    options: {
      Image: 'alpine',
      Cmd: ['echo', 'Hello World']
    }
  };
  docker.dial(opts, (err, data) => {
    if (err) throw err;
    console.log(data);
  });
};

createContainer();

Managing Images

This feature allows you to manage Docker images. The code sample demonstrates how to pull the 'alpine' image from Docker Hub.

const Docker = require('docker-modem');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });

const pullImage = async () => {
  const opts = {
    path: '/images/create',
    method: 'POST',
    options: {
      fromImage: 'alpine',
      tag: 'latest'
    }
  };
  docker.dial(opts, (err, data) => {
    if (err) throw err;
    console.log(data);
  });
};

pullImage();

Managing Networks

This feature allows you to manage Docker networks. The code sample demonstrates how to create a new network with the 'bridge' driver.

const Docker = require('docker-modem');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });

const createNetwork = async () => {
  const opts = {
    path: '/networks/create',
    method: 'POST',
    options: {
      Name: 'my_network',
      Driver: 'bridge'
    }
  };
  docker.dial(opts, (err, data) => {
    if (err) throw err;
    console.log(data);
  });
};

createNetwork();

Other packages similar to docker-modem

Keywords

FAQs

Package last updated on 28 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc